package kevin.workplan.database.dao;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.FROM;
import static org.apache.ibatis.jdbc.SqlBuilder.SELECT;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import kevin.workplan.database.gen.mapper.PlanSqlProvider;
import kevin.workplan.database.gen.model.PlanExample;

public class CPlanSqlProvider extends PlanSqlProvider {

	public String countByExample(PlanExample example) {
        BEGIN();
        SELECT("count(*)");
        FROM("plan");
        applyWhere(example, false);
        return SQL();
    }
	
	public String searchByExampleWithBLOBs(PlanExample example) {
        String sql = selectByExampleWithBLOBs(example);
        
        if(example.getOffset()!=null && example.getLimit()!=null) {
        	sql += " limit " + example.getOffset() + "," + example.getLimit();
        }
        
        return sql;
    }
}
